import Vue from 'vue'
import App from './App.vue'
// 引入Vue-route
import VueRouter from 'vue-router'
// import store from './vuex/store'
import Vuex from 'vuex'
import router from './router'
Vue.use(VueRouter)
Vue.use(Vuex)

// Element 引入
import ElementUI from 'element-ui';
import 'element-ui/lib/theme-chalk/index.css';
Vue.use(ElementUI);

// Mosk引入
import Mock from './mock'
Mock.bootstrap();

// 登陆拦截
router.beforeEach((to, from, next) => {
  //NProgress.start();
  if (to.path == '/login') {
    sessionStorage.removeItem('user');
  }
  let user = JSON.parse(sessionStorage.getItem('user'));
  if (!user && to.path != '/login') {
    next({ path: '/login' })
  } else {
    next()
  }
})

// Vue 根实例   
new Vue({
  el: '#app',
  // 挂载路由
  router,
  render: h => h(App),
})

